package com.example.quartz;

import org.quartz.*;

import java.util.Date;
import java.util.concurrent.TimeUnit;

/**
 * @Author: sn
 * @Desc something
 * @Date: 2021/8/27
 */
@DisallowConcurrentExecution
public class HelloQuartz implements Job {

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        JobDetail detail = jobExecutionContext.getJobDetail();
        String name = detail.getJobDataMap().getString("name");
        System.out.println("my job name is  " + name + " at " + new Date());
        try {
            TimeUnit.SECONDS.sleep(3);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("my job over");
    }
}
